package com.huha.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;

import java.math.BigDecimal;

public class calculatorcontroller {
    @FXML
    public void onClicked(ActionEvent event){
        // 获取点击的按钮
        Button button = (Button) event.getTarget();
        String input = button.getText();

        // 获取输出控件值
        String resultText = result.getText();

        try{
            int intinput = Integer.parseInt(input);
            if(resultText.length() >= 10){
                return;
            }
            long newVal = Long.parseLong(resultText) * 10 + intinput;

            // 展示到输出区
            result.setText(newVal + "");
        }
        catch (Exception e){
            result.setText("error");
        }


    }

    @FXML
    private Label result;

    @FXML
    private Label expression;
}
